package com.ciaojian.client.strategy.discount;

import com.ciaojian.client.enums.DiscountTypeEnum;
import com.ciaojian.client.factory.DiscountCalculatorFactory;
import org.springframework.stereotype.Component;

/**
 * 折扣优惠
 *
 * @author oxiny
 */
@Component
public class ZKIDiscount implements DiscountCalculator<Double> {
    /**
     * 折扣优惠计算器
     *
     * @param couponInfo 折扣折数
     * @param skuPrice   原金额
     * @return 优惠后的金额
     */
    @Override
    public Integer calculate(Double couponInfo, Integer skuPrice) {
        return (int) (skuPrice * couponInfo);
    }

    @Override
    public DiscountTypeEnum getType() {
        return DiscountTypeEnum.ZHE_KOU;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        DiscountCalculatorFactory.register(this);
    }
}
